home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / host contacted / jikes.lha / jikes-1.11 / src / op.h < prev    next >
C/C++ Source or Header  |  1999-05-05  |  7KB  |  282 lines

  1. // $Id: op.h,v 1.4 1999/05/05 14:18:00 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef op_INCLUDED
  11. #define op_INCLUDED
  12.  
  13. #include "config.h"
  14. #include "tuple.h"
  15.  
  16. class cp_info;
  17.  
  18. // code dealing with describing and listing byte code
  19. class Operators
  20. {
  21. public:
  22.     enum operators
  23.     {
  24.         OP_NOP = 0x00,
  25.         OP_ACONST_NULL = 0x01,
  26.         OP_ICONST_M1 = 0x02,
  27.         OP_ICONST_0 = 0x03,
  28.         OP_ICONST_1 = 0x04,
  29.         OP_ICONST_2 = 0x05,
  30.         OP_ICONST_3 = 0x06,
  31.         OP_ICONST_4 = 0x07,
  32.         OP_ICONST_5 = 0x08,
  33.         OP_LCONST_0 = 0x09,
  34.         OP_LCONST_1 = 0x0a,
  35.         OP_FCONST_0 = 0x0b,
  36.         OP_FCONST_1 = 0x0c,
  37.         OP_FCONST_2 = 0x0d,
  38.         OP_DCONST_0 = 0x0e,
  39.         OP_DCONST_1 = 0x0f,
  40.         OP_BIPUSH = 0x10,
  41.         OP_SIPUSH = 0x11,
  42.         OP_LDC = 0x12,
  43.         OP_LDC_W = 0x13,
  44.         OP_LDC2_W = 0x14,
  45.         OP_ILOAD = 0x15,
  46.         OP_LLOAD = 0x16,
  47.         OP_FLOAD = 0x17,
  48.         OP_DLOAD = 0x18,
  49.         OP_ALOAD = 0x19,
  50.         OP_ILOAD_0 = 0x1a,
  51.         OP_ILOAD_1 = 0x1b,
  52.         OP_ILOAD_2 = 0x1c,
  53.         OP_ILOAD_3 = 0x1d,
  54.         OP_LLOAD_0 = 0x1e,
  55.         OP_LLOAD_1 = 0x1f,
  56.         OP_LLOAD_2 = 0x20,
  57.         OP_LLOAD_3 = 0x21,
  58.         OP_FLOAD_0 = 0x22,
  59.         OP_FLOAD_1 = 0x23,
  60.         OP_FLOAD_2 = 0x24,
  61.         OP_FLOAD_3 = 0x25,
  62.         OP_DLOAD_0 = 0x26,
  63.         OP_DLOAD_1 = 0x27,
  64.         OP_DLOAD_2 = 0x28,
  65.         OP_DLOAD_3 = 0x29,
  66.         OP_ALOAD_0 = 0x2a,
  67.         OP_ALOAD_1 = 0x2b,
  68.         OP_ALOAD_2 = 0x2c,
  69.         OP_ALOAD_3 = 0x2d,
  70.         OP_IALOAD = 0x2e,
  71.         OP_LALOAD = 0x2f,
  72.         OP_FALOAD = 0x30,
  73.         OP_DALOAD = 0x31,
  74.         OP_AALOAD = 0x32,
  75.         OP_BALOAD = 0x33,
  76.         OP_CALOAD = 0x34,
  77.         OP_SALOAD = 0x35,
  78.         OP_ISTORE = 0x36,
  79.         OP_LSTORE = 0x37,
  80.         OP_FSTORE = 0x38,
  81.         OP_DSTORE = 0x39,
  82.         OP_ASTORE = 0x3a,
  83.         OP_ISTORE_0 = 0x3b,
  84.         OP_ISTORE_1 = 0x3c,
  85.         OP_ISTORE_2 = 0x3d,
  86.         OP_ISTORE_3 = 0x3e,
  87.         OP_LSTORE_0 = 0x3f,
  88.         OP_LSTORE_1 = 0x40,
  89.         OP_LSTORE_2 = 0x41,
  90.         OP_LSTORE_3 = 0x42,
  91.         OP_FSTORE_0 = 0x43,
  92.         OP_FSTORE_1 = 0x44,
  93.         OP_FSTORE_2 = 0x45,
  94.         OP_FSTORE_3 = 0x46,
  95.         OP_DSTORE_0 = 0x47,
  96.         OP_DSTORE_1 = 0x48,
  97.         OP_DSTORE_2 = 0x49,
  98.         OP_DSTORE_3 = 0x4a,
  99.         OP_ASTORE_0 = 0x4b,
  100.         OP_ASTORE_1 = 0x4c,
  101.         OP_ASTORE_2 = 0x4d,
  102.         OP_ASTORE_3 = 0x4e,
  103.         OP_IASTORE = 0x4f,
  104.         OP_LASTORE = 0x50,
  105.         OP_FASTORE = 0x51,
  106.         OP_DASTORE = 0x52,
  107.         OP_AASTORE = 0x53,
  108.         OP_BASTORE = 0x54,
  109.         OP_CASTORE = 0x55,
  110.         OP_SASTORE = 0x56,
  111.         OP_POP = 0x57,
  112.         OP_POP2 = 0x58,
  113.         OP_DUP = 0x59,
  114.         OP_DUP_X1 = 0x5a,
  115.         OP_DUP_X2 = 0x5b,
  116.         OP_DUP2 = 0x5c,
  117.         OP_DUP2_X1 = 0x5d,
  118.         OP_DUP2_X2 = 0x5e,
  119.         OP_SWAP = 0x5f,
  120.         OP_IADD = 0x60,
  121.         OP_LADD = 0x61,
  122.         OP_FADD = 0x62,
  123.         OP_DADD = 0x63,
  124.         OP_ISUB = 0x64,
  125.         OP_LSUB = 0x65,
  126.         OP_FSUB = 0x66,
  127.         OP_DSUB = 0x67,
  128.         OP_IMUL = 0x68,
  129.         OP_LMUL = 0x69,
  130.         OP_FMUL = 0x6a,
  131.         OP_DMUL = 0x6b,
  132.         OP_IDIV = 0x6c,
  133.         OP_LDIV = 0x6d,
  134.         OP_FDIV = 0x6e,
  135.         OP_DDIV = 0x6f,
  136.         OP_IREM = 0x70,
  137.         OP_LREM = 0x71,
  138.         OP_FREM = 0x72,
  139.         OP_DREM = 0x73,
  140.         OP_INEG = 0x74,
  141.         OP_LNEG = 0x75,
  142.         OP_FNEG = 0x76,
  143.         OP_DNEG = 0x77,
  144.         OP_ISHL = 0x78,
  145.         OP_LSHL = 0x79,
  146.         OP_ISHR = 0x7a,
  147.         OP_LSHR = 0x7b,
  148.         OP_IUSHR = 0x7c,
  149.         OP_LUSHR = 0x7d,
  150.         OP_IAND = 0x7e,
  151.         OP_LAND = 0x7f,
  152.         OP_IOR = 0x80,
  153.         OP_LOR = 0x81,
  154.         OP_IXOR = 0x82,
  155.         OP_LXOR = 0x83,
  156.         OP_IINC = 0x84,
  157.         OP_I2L = 0x85,
  158.         OP_I2F = 0x86,
  159.         OP_I2D = 0x87,
  160.         OP_L2I = 0x88,
  161.         OP_L2F = 0x89,
  162.         OP_L2D = 0x8a,
  163.         OP_F2I = 0x8b,
  164.         OP_F2L = 0x8c,
  165.         OP_F2D = 0x8d,
  166.         OP_D2I = 0x8e,
  167.         OP_D2L = 0x8f,
  168.         OP_D2F = 0x90,
  169.         OP_I2B = 0x91,
  170.         OP_I2C = 0x92,
  171.         OP_I2S = 0x93,
  172.         OP_LCMP = 0x94,
  173.         OP_FCMPL = 0x95,
  174.         OP_FCMPG = 0x96,
  175.         OP_DCMPL = 0x97,
  176.         OP_DCMPG = 0x98,
  177.         OP_IFEQ = 0x99,
  178.         OP_IFNE = 0x9a,
  179.         OP_IFLT = 0x9b,
  180.         OP_IFGE = 0x9c,
  181.         OP_IFGT = 0x9d,
  182.         OP_IFLE = 0x9e,
  183.         OP_IF_ICMPEQ = 0x9f,
  184.         OP_IF_ICMPNE = 0xa0,
  185.         OP_IF_ICMPLT = 0xa1,
  186.         OP_IF_ICMPGE = 0xa2,
  187.         OP_IF_ICMPGT = 0xa3,
  188.         OP_IF_ICMPLE = 0xa4,
  189.         OP_IF_ACMPEQ = 0xa5,
  190.         OP_IF_ACMPNE = 0xa6,
  191.         OP_GOTO = 0xa7,
  192.         OP_JSR = 0xa8,
  193.         OP_RET = 0xa9,
  194.         OP_TABLESWITCH = 0xaa,
  195.         OP_LOOKUPSWITCH = 0xab,
  196.         OP_IRETURN = 0xac,
  197.         OP_LRETURN = 0xad,
  198.         OP_FRETURN = 0xae,
  199.         OP_DRETURN = 0xaf,
  200.         OP_ARETURN = 0xb0,
  201.         OP_RETURN = 0xb1,
  202.         OP_GETSTATIC = 0xb2,
  203.         OP_PUTSTATIC = 0xb3,
  204.         OP_GETFIELD = 0xb4,
  205.         OP_PUTFIELD = 0xb5,
  206.         OP_INVOKEVIRTUAL = 0xb6,
  207.         OP_INVOKENONVIRTUAL = 0xb7,
  208.         OP_INVOKESTATIC = 0xb8,
  209.         OP_INVOKEINTERFACE = 0xb9,
  210.         OP_XXXUNUSEDXXX = 0xba,
  211.         OP_NEW = 0xbb,
  212.         OP_NEWARRAY = 0xbc,
  213.         OP_ANEWARRAY = 0xbd,
  214.         OP_ARRAYLENGTH = 0xbe,
  215.         OP_ATHROW = 0xbf,
  216.         OP_CHECKCAST = 0xc0,
  217.         OP_INSTANCEOF = 0xc1,
  218.         OP_MONITORENTER = 0xc2,
  219.         OP_MONITOREXIT = 0xc3,
  220.         OP_WIDE = 0xc4,
  221.         OP_MULTIANEWARRAY = 0xc5,
  222.         OP_IFNULL = 0xc6,
  223.         OP_IFNONNULL = 0xc7,
  224.         OP_GOTO_W = 0xc8,
  225.         OP_JSR_W = 0xc9,
  226.         OP_SOFTWARE = 0xfe,
  227.         OP_HARDWARE = 0xff
  228.     };
  229.  
  230.     static void opdmp(Tuple<cp_info *> &, Tuple<u1> &);
  231.  
  232. protected:
  233.  
  234.     static int stack_effect[];
  235.  
  236. private:
  237.  
  238.     enum
  239.     {
  240.         INFO_NONE = 0,
  241.         INFO_LOCAL = 1,
  242.         INFO_CONST = 2,
  243.         INFO_DONE  = 3
  244.     };
  245.  
  246.     static void opdesc (int opc, char **name, char **desc);
  247.  
  248.     inline static signed char get_i1(Tuple<u1> &code, int pc)
  249.     {
  250.         return code[pc];
  251.     }
  252.  
  253.     inline static short get_i2(Tuple<u1> &code, int pc)
  254.     {
  255.         return  code[pc] << 8 | code[pc + 1];
  256.     }
  257.  
  258.     inline static int get_i4(Tuple<u1> &code, int pc)
  259.     {
  260.         return  code[pc] << 24 | code[pc + 1] << 16 | code[pc + 2] << 8 | code[pc + 3];
  261.     }
  262.  
  263.     inline static unsigned get_u1(Tuple<u1> &code, int pc)
  264.     {
  265.         return code[pc];
  266.     }
  267.  
  268.     inline static unsigned get_u2(Tuple<u1> &code, int pc)
  269.     {
  270.         return (unsigned) (code[pc] << 8 | code[pc + 1]);
  271.     }
  272.  
  273.     inline static unsigned get_u4(Tuple<u1> &code, int pc)
  274.     {
  275.         return (unsigned) (code[pc] << 24 | code[pc + 1] << 16 | code[pc + 2] << 8 | code[pc + 3]);
  276.     }
  277.  
  278.     static void opline(Tuple<cp_info *> &, char *, int, int, char *, char *, char *, int, int);
  279. };
  280.  
  281. #endif
  282.